package hn.sigit.model.ladm.administrative;

import java.io.Serializable;
import javax.persistence.*;
@Embeddable
public class LA_RequiredRelationshipBAUnitPK implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private long baunits2La_baunitId;
	private long baunits1La_baunitId;
	private hn.sigit.model.ladm.administrative.LA_BAUnit baunits2La_baunit;
	private hn.sigit.model.ladm.administrative.LA_BAUnit baunits1La_baunit;

	
	@Id
	@Column(name="LA_BAUnitID", nullable=false)
	@GeneratedValue(generator="la_requiredrelationshipbaunitpk")
	@org.hibernate.annotations.GenericGenerator(name="la_requiredrelationshipbaunitpk", strategy="foreign", parameters=@org.hibernate.annotations.Parameter(name="property", value="Id"))
	public long getBaunits2La_baunitId() {
		return baunits2La_baunitId;
	}
	protected void setBaunits2La_baunitId(long value) {
		this.baunits2La_baunitId = value;
	}

	@Id
	@Column(name="LA_BAUnitID2", nullable=false)
	@GeneratedValue(generator="la_requiredrelationshipbaunitpk2")
	@org.hibernate.annotations.GenericGenerator(name="la_requiredrelationshipbaunitpk2", strategy="foreign", parameters=@org.hibernate.annotations.Parameter(name="property", value="Id"))
	public long getBaunits1La_baunitId() {
		return baunits1La_baunitId;
	}
	protected void setBaunits1La_baunitId(long value) {
		this.baunits1La_baunitId = value;
	}

	@PrimaryKeyJoinColumn
	@ManyToOne(targetEntity=hn.sigit.model.ladm.administrative.LA_BAUnit.class)
	@org.hibernate.annotations.Cascade({org.hibernate.annotations.CascadeType.LOCK})
	@JoinColumns({ @JoinColumn(name="LA_BAUnitID", referencedColumnName="ID") })
	public hn.sigit.model.ladm.administrative.LA_BAUnit getBaunits2La_baunit()  {
		return this.baunits2La_baunit;
	}
	public void setBaunits2La_baunit(hn.sigit.model.ladm.administrative.LA_BAUnit value)  {
		this.baunits2La_baunit =  value;
	}
	
	@PrimaryKeyJoinColumn
	@ManyToOne(targetEntity=hn.sigit.model.ladm.administrative.LA_BAUnit.class)	
	@org.hibernate.annotations.Cascade({org.hibernate.annotations.CascadeType.LOCK})	
	@JoinColumns({ @JoinColumn(name="LA_BAUnitID2", referencedColumnName="ID") })
	public hn.sigit.model.ladm.administrative.LA_BAUnit getBaunits1La_baunit()  {
		return this.baunits1La_baunit;
	}
	public void setBaunits1La_baunit(hn.sigit.model.ladm.administrative.LA_BAUnit value)  {
		this.baunits1La_baunit =  value;
	}

	
	public boolean equals(Object aObj) {
		if (aObj == this)
			return true;
		if (!(aObj instanceof LA_RequiredRelationshipBAUnitPK))
			return false;
		LA_RequiredRelationshipBAUnitPK la_requiredrelationshipbaunitpk = (LA_RequiredRelationshipBAUnitPK)aObj;
		if (getBaunits2La_baunit() == null) {
			if (la_requiredrelationshipbaunitpk.getBaunits2La_baunit() != null)
				return false;
		}
		else if (!getBaunits2La_baunit().equals(la_requiredrelationshipbaunitpk.getBaunits2La_baunit()))
			return false;
		if (getBaunits1La_baunit() == null) {
			if (la_requiredrelationshipbaunitpk.getBaunits1La_baunit() != null)
				return false;
		}
		else if (!getBaunits1La_baunit().equals(la_requiredrelationshipbaunitpk.getBaunits1La_baunit()))
			return false;
		return true;
	}
	
	public int hashCode() {
		int hashcode = 0;
		if (getBaunits2La_baunit() != null) {
			hashcode = hashcode + (int) getBaunits2La_baunit().getORMID();
		}
		if (getBaunits1La_baunit() != null) {
			hashcode = hashcode + (int) getBaunits1La_baunit().getORMID();
		}
		return hashcode;
	}
}
